home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / VideoToolbox 95.04.18 / VideoToolboxSources / GetClicks.c < prev    next >
Text File  |  1994-08-01  |  1KB  |  34 lines

  1. /*
  2. GetClicks.c
  3. waits for a mouse click, and then counts clicks (e.g. double-click, triple-click). Each
  4. click must arrive within the acceptable double-click time of the previous,
  5. as set in the Control Panel. Returns the number of clicks, 1 or more.
  6. HISTORY:
  7. 4/30/88 dgp    wrote it
  8. 3/31/90    dgp    cleaned up code and documentation.
  9. 8/24/91    dgp    Made compatible with THINK C 5.0.
  10. 3/30/91    dgp    use SndStop1() instead of obsolete Sound Driver.
  11. 1/25/93 dgp removed obsolete support for THINK C 4.
  12. */
  13. #include "VideoToolbox.h"
  14.  
  15. short GetClicks(void)
  16. {
  17.     long ticks;
  18.     EventRecord myEvent;
  19.     short clicks;
  20.  
  21.     clicks=0;
  22.     while(!GetNextEvent(mDownMask,&myEvent)) ;
  23.     SndStop1();    /* Stop sound on first click */
  24.     clicks++;
  25.     ticks=TickCount()+GetDblTime();
  26.     while(!GetNextEvent(mUpMask,&myEvent)) ;
  27.     while(TickCount() < ticks)    /* wait as long a possible for another click */
  28.         if(GetNextEvent(mDownMask,&myEvent)){
  29.             clicks++;
  30.             ticks=TickCount()+GetDblTime();
  31.             while(!GetNextEvent(mUpMask,&myEvent)) ;
  32.         }
  33.     return clicks;
  34. }